package nav

/*
#include<stdint.h>
#include<stdbool.h>
extern void * nav_dtAlloc(unsigned long long size,unsigned int hint);
extern void nav_dtFree(void * ptr);

*/
import "C"
import "unsafe"
import "gitee.com/hasika/cgo"

var _ unsafe.Pointer
var _ cgo.NotUsed

/*
Allocates a memory block.

@param size The size, in bytes of memory, to allocate.
@param hint A hint to the allocator on how long the memory is expected to be in use.
@return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
@see dtFree

void * dtAlloc(size_t size, dtAllocHint hint)
*/
func DtAlloc(size uint64, hint EnumDtAllocHint) uintptr {
	var wrap_arg_size C.ulonglong
	var wrap_arg_hint C.uint
	wrap_arg_size = (C.ulonglong)(size)
	wrap_arg_hint = (C.uint)(hint)
	wrap_out := C.nav_dtAlloc(wrap_arg_size, wrap_arg_hint)
	go_out := (uintptr)(unsafe.Pointer(wrap_out))
	return go_out
}

/*
Deallocates a memory block.

@param ptr A pointer to a memory block previously allocated using #dtAlloc.
@see dtAlloc

void dtFree(void * ptr)
*/
func DtFree(ptr uintptr) {
	var wrap_arg_ptr unsafe.Pointer
	wrap_arg_ptr = (unsafe.Pointer)(ptr)
	C.nav_dtFree(wrap_arg_ptr)
}

/*
Provides hint values to the memory allocator on how long the
memory is expected to be used.
*/
type EnumDtAllocHint uint32

const (
	/*
	   Memory persist after a function call.
	*/
	EnumDtAllocHint_DT_ALLOC_PERM EnumDtAllocHint = 0
	/*
	   Memory used temporarily within a function.
	*/
	EnumDtAllocHint_DT_ALLOC_TEMP EnumDtAllocHint = 1
)
